package com.ruoyi.web.controller.tool;

import java.util.List;

import com.ruoyi.system.domain.vo.JzToursArticleVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JzToursArticle;
import com.ruoyi.system.service.IJzToursArticleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 文章资讯Controller
 * 
 * @author ruoyi
 * @date 2021-03-18
 */
@RestController
@RequestMapping("/system/article")
@Api("文章资讯")
public class JzToursArticleController extends BaseController
{
    @Autowired
    private IJzToursArticleService jzToursArticleService;

    /**
     * 查询文章资讯列表
     */
    @PreAuthorize("@ss.hasPermi('system:article:list')")
    @GetMapping("/list")
    public TableDataInfo list(JzToursArticle jzToursArticle)
    {
        startPage();
        List<JzToursArticle> list = jzToursArticleService.selectJzToursArticleList(jzToursArticle);
        return getDataTable(list);
    }

    /**
     * 导出文章资讯列表
     */
    @PreAuthorize("@ss.hasPermi('system:article:export')")
    @Log(title = "文章资讯", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(JzToursArticle jzToursArticle)
    {
        List<JzToursArticle> list = jzToursArticleService.selectJzToursArticleList(jzToursArticle);
        ExcelUtil<JzToursArticle> util = new ExcelUtil<JzToursArticle>(JzToursArticle.class);
        return util.exportExcel(list, "article");
    }

    /**
     * 获取文章资讯详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:article:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(jzToursArticleService.selectJzToursArticleById(id));
    }

    /**
     * 新增文章资讯
     */
   @PreAuthorize("@ss.hasPermi('system:article:add')")
    @Log(title = "文章资讯", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增文章资讯")
    public AjaxResult add(@RequestBody JzToursArticleVo jzToursArticle)
    {
        return toAjax(jzToursArticleService.insertJzToursArticle(jzToursArticle));
    }

    /**
     * 修改文章资讯
     */
   @PreAuthorize("@ss.hasPermi('system:article:edit')")
    @Log(title = "文章资讯", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改文章资讯")
    public AjaxResult edit(@RequestBody JzToursArticleVo jzToursArticle)
    {
        return toAjax(jzToursArticleService.updateJzToursArticle(jzToursArticle));
    }


    /**
     * 删除文章资讯
     */
    @PreAuthorize("@ss.hasPermi('system:article:remove')")
    @Log(title = "文章资讯", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long ids)
    {
        return toAjax(jzToursArticleService.deleteJzToursArticleById(ids));
    }


}
